<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title></title>
    <link rel="stylesheet" type="text/css" href="../css/aui.css"/>
    <link rel="stylesheet" type="text/css" href="../css/style.css"/>
    <link rel="stylesheet" type="text/css" href="../css/iconfont.css"/>
    <style type="text/css">
        .text-white {
            color: #ffffff !important;
        }
        .aui-grid [class*=aui-col-] {
            padding: 0.75rem 0;
        }
        .iconfont{
          font-size: 1.5rem
        }
    </style>
</head>
<body>
    <!-- 顶部 -->
    <section class="myui-bg-info" id="user-info">
        <div class="user-box">
          <div class="user-box-1" tapmode onclick="toLogin()">
            <img src="../image/user_img.png">
          </div>
          <div id="islogin" class="user-box-2" style="font-size:1rem;color:#8e726f;" onclick="toLogin()">
              VIP影视
          </div>
          <div id="time" class="user-box-2" style="font-size:0.7rem;color:#ff5722;" onclick="toLogin()">
            <!-- <i class="iconfont icon-huiyuan" style="font-size:0.7rem;color:#fff940"></i>
            2018-03-01 15:00到期 -->
          </div>

        </div>
    </section>
    <div class="br"></div>
    <section class="aui-grid aui-margin-b-15">
        <div class="aui-row">
            <div class="aui-col-xs-4" onclick="openWin('open_vip_win')">
                <div class="aui-dot"></div>
                <i class="iconfont icon-wodeiconvip2"></i>
                <div class="aui-grid-label">充值</div>
            </div>
            <div class="aui-col-xs-4" onclick="openWin('jifen_win')">
                <i class="iconfont icon-jifen"></i>
                <div class="aui-grid-label">积分</div>
            </div>
            <div class="aui-col-xs-4" onclick="openWin('share_win')">
                <i class="iconfont icon-yaoqingma"></i>
                <div class="aui-grid-label">邀请</div>
            </div>
            <div class="aui-col-xs-4" onclick="openWin('back_pwd')">
                <i class="iconfont icon-mima54"></i>
                <div class="aui-grid-label">修改密码</div>
            </div>
            <div class="aui-col-xs-4" onclick="kefu()">
                <i class="iconfont icon-zaixianfuwuxian"></i>
                <div class="aui-grid-label">联系客服</div>
            </div>
            <div class="aui-col-xs-4" onclick="openWin('shezhi_win')">
                <i class="iconfont icon-shezhi"></i>
                <div class="aui-grid-label">设置</div>
            </div>
        </div>
    </section>
    <div class="br">

    </div>
    <div id="vsion" class="user-bt" onclick="alert('免责声明:本站所有视频均来自互联网，版权归原创者所有，如果侵犯了您的权益，请通知我们，我们将会在3个正常工作日内删除其侵权内容，谢谢合作。')">

    </div>
</body>
<script type="text/javascript" src="../script/api.js" ></script>
<script type="text/javascript">
    var api_url = localStorage.getItem('api_url');
    apiready = function () {
      api.parseTapmode();
      var appVersion = api.appVersion;
      var vsion = $api.byId('vsion');
      vsion.innerHTML = 'VIP影视 v'+appVersion+' <span style="color:#7bbfea">免责声明</span>';
      //监听重新获取客服联系方式广播
      api.addEventListener({
          name: 'newLoingdata'
      }, function(ret, err) {
        if (ret) {
          getData();
          location.reload();
        }
      });

      getData();

    }


    //联系客服按钮
    function kefu(){
      if (localStorage.getItem('user_id')<1) {
        api.alert({
            title: '请先登录',
            msg: '知道了',
        });
      }else {
        var dialogBox = api.require('dialogBox');
        dialogBox.alert({
            texts: {
                content: localStorage.getItem('user_weichat'),
                leftBtnTitle: '知道了',
                rightBtnTitle: '复制'
            },
            styles: {
                bg: '#fff',
                w: 300,
                content: {
                    color: '#000',
                    size: 14
                },
                left: {
                    marginB: 7,
                    marginL: 20,
                    w: 130,
                    h: 35,
                    corner: 2,
                    bg: '#ff7600',
                    color: '#fff',
                    size: 14
                },
                right: {
                    marginB: 7,
                    marginL: 10,
                    w: 130,
                    h: 35,
                    corner: 2,
                    bg: '#ff7600',
                    color: '#fff',
                    size: 14
                }
            }
        }, function(ret) {
            if (ret.eventType == 'left') {
                var dialogBox = api.require('dialogBox');
                dialogBox.close({
                    dialogName: 'alert'
                });
            }else if (ret.eventType == 'right') {
              var clipBoard = api.require('clipBoard');
              clipBoard.set({
                  value: localStorage.getItem('user_weichat')
              }, function(ret, err) {
                  if (ret) {
                    api.toast({
                        msg: '已复制号码到剪切板',
                        duration: 2000
                    });
                    var dialogBox = api.require('dialogBox');
                    dialogBox.close({
                        dialogName: 'alert'
                    });
                  } else {

                  }
              });
            }
        });
      }
    }


    function openWin(name){
      if (localStorage.getItem('user_id')<1) {
        api.openWin({
            name: 'login',
            url: './login.html',
        });
        return;
      }else {
        var delay = 0;
        if(api.systemType != 'ios'){
            delay = 300;
        }

        api.openWin({
            name: ''+name+'',
            url: ''+name+'.html',
            bounces:false,
            delay: delay,
            slidBackEnabled:true,
            vScrollBarEnabled:false
        });
      }

    }
    //获取数据
    function getData(){
      var user_id = localStorage.getItem('user_id');
      var user_name = localStorage.getItem('user_name');
      var user_time = localStorage.getItem('user_time');
      var s1 = formatDateTime(user_time);
      var timestamp = Date.parse(new Date())/1000;
      var time = $api.byId('time');
      var islogin = $api.byId('islogin');
      //alert(user_time);
      if (user_time>timestamp) {
        time.innerHTML = '<i class="iconfont icon-huiyuan" style="font-size:0.7rem;color:#ff5722"></i> VIP '+s1+' 到期';
      }
      if (user_time<timestamp) {
        time.innerHTML = '<i class="iconfont icon-huiyuan" style="font-size:0.7rem;color:#ff5722"></i> VIP已到期 请及时续费';
      }
      if(user_time == "-1") {
        time.innerHTML = '<i class="iconfont icon-huiyuan" style="font-size:0.7rem;color:#ff5722"></i> 永久贵宾VIP';
      }
      if (localStorage.getItem('user_id')<1) {
        time.innerHTML = '请先登陆';
      }
      if (localStorage.getItem('user_id')>1) {
        islogin.innerHTML = user_name;
      }



      // if (user_id>0) {
      //
      //   api.ajax({
      //       url: api_url+'/login/login/sign.html',
      //       method: 'get',
      //       data: {
      //           values: {
      //               uid: user_id
      //           }
      //       }
      //   },function(ret, err){
      //       if (ret) {
      //
      //           shareid.innerHTML = ret.msg['share']+'<small> 分</small>';
      //       } else {
      //           alert('网络错误');
      //       }
      //   });
      //
      //
      //   if (user_time>timestamp) {
      //     invip.innerHTML = '<i class="iconfont icon-VIP" style="font-size:0.8rem;color:#fff940;"></i>VIP会员';
      //     stime.innerHTML = time+'<small> 天</small>';
      //
      //
      //   }else if (user_time == -1) {
      //     invip.innerHTML = '<i class="iconfont icon-VIP" style="font-size:0.8rem;color:#fff940;"></i>永久VIP';
      //     stime.innerHTML = '<small> 一万年</small>';
      //   }else if (user_time<timestamp) {
      //     stime.innerHTML = '<small> 已到期</small>';
      //   }else if (time == 0) {
      //     stime.innerHTML = '<small>体验卡</small>';
      //   }
      // }else {
      //   islogin.style.display = "none";
      //   no_login.style.display = "block";
      //   invip.style.display = "none";
      //   otbtn.style.display = "none";
      //   indata.style.display = "none";
      //   api.hideProgress();
      //
      // }
    }



    function formatDateTime(timeStamp) {
        var date = new Date();
        date.setTime(timeStamp * 1000);
        var y = date.getFullYear();
        var m = date.getMonth() + 1;
        m = m < 10 ? ('0' + m) : m;
        var d = date.getDate();
        d = d < 10 ? ('0' + d) : d;
        var h = date.getHours();
        h = h < 10 ? ('0' + h) : h;
        var minute = date.getMinutes();
        var second = date.getSeconds();
        minute = minute < 10 ? ('0' + minute) : minute;
        second = second < 10 ? ('0' + second) : second;
        return y + '-' + m + '-' + d;
    };


    function toLogin(){
      if (localStorage.getItem('user_id')>0) {
          api.openWin({
              name: 'open_vip_win',
              url: './open_vip_win.html',
              delay: 300,
          });
      }else {
        api.openWin({
            name: 'login',
            url: './login.html',
            delay: 300,
        });
      }

    }

    function toVip(){
      if (user_id>0) {
        api.openWin({
            name: 'open_vip_win',
            url: './open_vip_win.html',
            delay: 300,
        });

      }else {
        api.openWin({
            name: 'login',
            url: './login.html',
            delay: 300,
        });

      }

    }

    //退出登录
    function exitLogin(){
      api.showProgress({
          title: '稍后...',
          text: '正在退出...',
          modal: false
      });
      localStorage.setItem('user_id','');
      localStorage.setItem('user_name','');
      localStorage.setItem('user_time','');


      getData();


    }
</script>
</html>
